package com.project.controller;

import com.project.bean.CheckCarBean;
import com.project.service.ICheckCarService;
import com.project.util.InfoResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lyl
 * description:
 */
@RestController
@RequestMapping("checkCar")
@Api(tags = "销售出库controller")
public class CheckCarController {
    @Autowired
    private ICheckCarService iCheckCarService;

    @PostMapping("addCheckToCar/{userId}/{productId}/{clientId}")
    private InfoResult addCheckToCar(@PathVariable int userId,
                                     @PathVariable int productId,
                                     @PathVariable int clientId) {
        return iCheckCarService.addCheckToCar(userId, productId, clientId);
    }

    @GetMapping("showCheckCarbyId/{userId}/{clientId}")
    private List<CheckCarBean> showCheckCarById(@PathVariable int userId,
                                                @PathVariable int clientId) {
        return iCheckCarService.showCheckCarById(userId, clientId);
    }

    @GetMapping("updateCheckCarInfo/{userId}/{productId}/{checkNum}")
    private InfoResult updateCheckCarInfo(@PathVariable int userId,
                                          @PathVariable int productId,
                                          @PathVariable int checkNum) {
        return iCheckCarService.updateCheckCarInfo(userId, productId, checkNum);
    }

    @PostMapping("checkOut/{userId}/{clientId}/{address}")
    private InfoResult checkOut(@PathVariable int userId,
                                @PathVariable int clientId,
                                @PathVariable String address) {
        return iCheckCarService.checkOut(userId, clientId, address);
    }

    @DeleteMapping("remove/{checkCarId}")
    private InfoResult remove(@PathVariable int checkCarId) {
        return iCheckCarService.remove(checkCarId);
    }

}
